<?php
namespace Admin\Models\user;

use Admin\Models\BaseModel;

class XhsysUserstud extends BaseModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iUserId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     * @explain 教师子女类型，1=非，2=收费教师子女，3=免费教师子女
     */
    public $iTchChild;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iDevCost;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iSerCost;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     * @explain 是否留守儿童，0=否，1=是
     */
    public $iBehind;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     * @explain 设备注册码
     */
    public $sAuthCode;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     * @explain 设备注册码是否可用(1=可用，0=不可用)
     */
    public $bAuthUseful;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $sMotherName;

    /**
     *
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $sFatherName;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $sOtherName;

    /**
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iExpireTime;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * @var integer
     */
    public $iHistoryType;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHSys_UserStud';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysUserstud[]|XhsysUserstud|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysUserstud|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 获取初始化对象
     *
     * @param $userId
     * @return XhsysUserstud|\Phalcon\Mvc\Model\ResultInterface
     *
     * create by ck 20180914
     */
    public static function getInitObj($userId)
    {
        $obj = self::findFirst($userId);
        if (!$obj) {
            $obj = new self(['iUserId' => $userId]);
        }
        return $obj;
    }
}
